package com.ibiaoke.boss.controller;

import com.ibiaoke.common.response.Res;
import com.ibiaoke.goods.entity.XcxShopPrice;
import com.ibiaoke.goods.service.XcxShopPriceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 小程序的配置库存
 */
@Controller
public class BossXcxShopPriceController {

    @Autowired
    private XcxShopPriceService xcxShopPriceService;

    /**
     * 添加店铺商品(批量)
     * @param xcxShopPrices
     * @return
     */
    @ResponseBody
    @RequestMapping("/batchSaveXcxShopPrice")
    public Res batchSaveXcxShopPrice(@RequestBody List<XcxShopPrice> xcxShopPrices){
        xcxShopPriceService.batchSaveShopPrice(xcxShopPrices);
        return Res.create();
    }

    /**
     * 添加店铺商品
     * @param xcxShopPrices
     * @return
     */
    @ResponseBody
    @RequestMapping("/saveXcxShopPrice")
    public Res saveXcxShopPrice(XcxShopPrice xcxShopPrices){
        xcxShopPriceService.saveShopPrice(xcxShopPrices);
        return Res.create();
    }

    /**
     * 查询商品店铺价格和库存
     * @param xcxGoodsId
     * @return
     */
    @ResponseBody
    @RequestMapping("/listXcxShopPrice")
    public Res listXcxShopPrice(Integer xcxGoodsId) {
        List<XcxShopPrice> shopPrices = xcxShopPriceService.listShopPrice(xcxGoodsId);
        return Res.create().addResponse("shopPrices",shopPrices);
    }
}
